package com.qiangesoft.encryption.controller;

import cn.shuibo.annotation.Decrypt;
import cn.shuibo.annotation.Encrypt;
import com.alibaba.fastjson.JSON;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

/**
 * 测试
 *
 * @author qiangesoft
 * @date 2024-05-22
 */
@Slf4j
@RequestMapping("/test")
@RestController
public class TestController {

    @PostMapping("/add")
    public void add(@RequestBody UserDTO userDTO) {
        log.info(JSON.toJSONString(userDTO));
    }

    @Encrypt
    @GetMapping("/encryption")
    public UserDTO encryption() {
        UserDTO userDTO = new UserDTO();
        userDTO.setUsername("admin");
        userDTO.setPassword("123456");
        userDTO.setNickname("超级管理员");
        userDTO.setSex("男");
        userDTO.setAge(29);
        userDTO.setTelephone("13333333333");
        userDTO.setAddress("北京市西城区");
        return userDTO;
    }

    @Decrypt
    @PostMapping("/decryption")
    public UserDTO decryption(@RequestBody UserDTO userDTO) {
        return userDTO;
    }

}
